import request from "../request";
// 分类的借口地址
const CATE_URL = "/home/category/head";
const BRAND_URL = "/home/brand";
const BANNER_USER = "/home/banner";
const NEW_URL = "/home/new";
const HOT_URL = "/home/hot";
const GOODS_URL = "/home/goods";
const SPECIAL_URL = "/home/special";
const CATEGORY_URL = "/category";
const CATEFILTER_URL = "/category/sub/filter";
const TOP_URL = "/category/goods/temporary";
/*
    分类数据是api
*/

export function getCate() {
  return request({
    url: CATE_URL,
    method: "get",
  });
}

/*
    品牌数据是api
*/

export function getbrand(limit = 6) {
  return request({
    url: BRAND_URL,
    method: "get",
    params: { limit },
  });
}

/*
    品牌数据是api
*/

export function getbanner(distributionSite = 1) {
  return request({
    url: BANNER_USER,
    method: "get",
    params: { distributionSite },
  });
}

/*
    新鲜好物数据是api
*/

export function getNew(limit = 4) {
  return request({
    url: NEW_URL,
    method: "get",
    params: { limit },
  });
}

/*
    人气推荐数据是api
*/

export function getHot() {
  return request({
    url: HOT_URL,
    method: "get",
  });
}

/*
    热门品牌数据是api
*/
export function getBrand(limit = 10) {
  return request({
    url: BRAND_URL,
    method: "get",
    params: { limit },
  });
}

/*
    热门品牌数据是api
*/
export function getGoods() {
  return request({
    url: GOODS_URL,
    method: "get",
  });
}

/*
    最新专题数据是api
*/
export function getSpecial() {
  return request({
    url: SPECIAL_URL,
    method: "get",
  });
}

/*
    最新专题数据是api
*/
export function getCategory(id) {
  // console.log(id);
  return request({
    url: CATEGORY_URL + "?id=" + id,
    method: "get",
    // params:{id}
  });
}

/*
    二级分类筛选数据是api
*/
export function getFilter(id) {
  // console.log(id);
  return request({
    url: CATEFILTER_URL,
    method: "get",
    params: { id },
  });
}

/*
    二级分类筛选数据是api
    params 是参数对象
*/
export function getTop(params) {
  // console.log(id);
  return request({
    url: TOP_URL,
    method: "post",
    data: params,
  });
}

//获取当前商品的详情信息
export function getdetail(id) {
  // console.log(id);
  return request({
    url: "/goods",
    method: "get",
    params:{id}
  });
}